# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-h2
pkgver=4.1.0
pkgrel=3
pkgdesc="HTTP/2 State-Machine based protocol implementation"
arch=('any')
license=('MIT')
url="https://hyper.rtfd.org"
depends=('python-hpack' 'python-hyperframe')
makedepends=('python-setuptools')
checkdepends=('python-pytest-runner' 'python-hypothesis')
source=("https://github.com/python-hyper/h2/archive/v$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-python-3.11.patch::https://github.com/python-hyper/h2/pull/1274.patch)
sha512sums=('4e9cf88b3ae702a8a42bded775ad337809787fe8172d501c230d55abbf1edd764acf3b227f2e58756d882499661ffcf6bbdd4812a4d938c04fac3f1aa2390b28'
            '94c0c5f6a5146e76c0ca9ccd62c7acfb7073b520ffe41a80cfaf51f619af5966d8beac923ca89bc439ec7170fd4c07d016b9024afce39a430214d6a8c8af6595')

prepare() {
  cd h2-$pkgver
  patch -p1 -i ../$pkgname-python-3.11.patch
}

build() {
  cd h2-$pkgver
  python setup.py build
}

check() {
  cd h2-$pkgver
  python setup.py pytest
}

package() {
  cd h2-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
